<?php namespace web\home\controller;

/**
 * 首页数据循环
 * 刘超群
 * 2016年10月12日21:36:19
 */
class Entry {
	//首页
	public function index() {
		//hover数据
		$proData = Db::table('goods')->where('cid',8)->limit(3)->get();
		View::with('proData',$proData);
		$blueData = Db::table('goods')->where('cid',9)->limit(3)->get();
//        p($blueData);
		View::with('blueData',$blueData);
		$_SESSION['home']['userurl'] = $_SERVER['REQUEST_URI'];
		$page=Db::table('category')->where('pid',0)->get();
//		p($page);
		foreach ($page as $k=>$v){
				$page[$k]['cids'] =Db::table('category')->where('pid',$v['cid'])->lists('cid');
				$page[$k]['goods']=Db::table('goods')->join('category','category.cid','=','goods.cid')->whereIn('goods.cid',$page[$k]['cids'])->limit(10)->get();
		}
//		p($page);
		View::with('page',$page);
		$typeData=Db::table('type')->get();
		foreach ($typeData as $k=>$v){
			$typeData[$k]['data']=Db::table('goods')->where('tid',$v['tid'])->whereNotIn('click',[5])->limit(10)->get();
			$typeData[$k]['cot']=Db::table('goods')->where('tid',$v['tid'])->where('click',5)->limit(10)->get();
		}
//		p($typeData);
		View::with('typeData',$typeData);
		$goodsData=Db::table('goods')->orderBy('rand()')->whereNotIn('click',[5])->limit(5)->get();
//		p($goodsData);
		View::with('goodsData',$goodsData);
		View::make();
	}
}